<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="elForm" :model="user" :rules="rules" size="medium" label-width="100px">
        <el-col :span="14">
          <el-form-item label="用户名" prop="uname">
            <el-input v-model="user.uname" placeholder="用户名" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="电话" prop="utel">
            <el-input v-model="user.utel" placeholder="请输入电话" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="性别" prop="usex">
            <el-radio-group v-model="user.usex" size="medium">
              <el-radio v-for="(item, index) in field103Options" :key="index" :label="item.value"
                        :disabled="item.disabled">{{item.label}}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="生日" prop="ubirth">
            <el-date-picker v-model="user.ubirth" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                            :style="{width: '100%'}" placeholder="请选择生日" clearable></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="毕业院校" prop="uschool">
            <el-input v-model="user.uschool" placeholder="请输入毕业院校" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="学历" prop="ueduction">
            <el-input v-model="user.ueduction" placeholder="请输入学历":style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="行业" prop="uindustry">
            <el-input v-model="user.uindustry" placeholder="请输入行业" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="行业" prop="uwork">
            <el-input v-model="user.uwork" placeholder="请输入行业" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="邮箱" prop="uemail">
            <el-input v-model="user.uemail" placeholder="请输入邮箱" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
  export default {
    components: {},
    props: [],
    data() {
      return {
        user:{
         },
        rules: {
          field101: [{
            required: true,
            message: '用户名',
            trigger: 'blur'
          }],
          field102: [{
            required: true,
            message: '请输入电话',
            trigger: 'blur'
          }],
          field103: [{
            required: true,
            message: '性别不能为空',
            trigger: 'change'
          }],
          field113: [{
            required: true,
            message: '请选择生日',
            trigger: 'change'
          }],
          field105: [{
            required: true,
            message: '请输入毕业院校',
            trigger: 'blur'
          }],
          field106: [{
            required: true,
            message: '请输入学历',
            trigger: 'blur'
          }],
          field107: [{
            required: true,
            message: '请输入行业',
            trigger: 'blur'
          }],
          field108: [{
            required: true,
            message: '请选择工作',
            trigger: 'change'
          }],
          field110: [{
            required: true,
            message: '请输入单行文本',
            trigger: 'blur'
          }],
          field111: [{
            required: true,
            message: '请选择时间选择',
            trigger: 'change'
          }],
          field114: [{
            required: true,
            message: '请输入邮箱',
            trigger: 'blur'
          }],
          field117: [{
            required: true,
            message: '请输入注册时间',
            trigger: 'blur'
          }],
          field118: [{
            required: true,
            message: '请输入更新时间',
            trigger: 'blur'
          }],
          field120: [{
            required: true,
            message: '请输入version',
            trigger: 'blur'
          }],
          field121: [{
            required: true,
            message: '请输入用户标识',
            trigger: 'blur'
          }],
          field122: [{
            required: true,
            message: '请选择下拉选择',
            trigger: 'change'
          }],
          field123: [{
            required: true,
            message: '请输入是否注销',
            trigger: 'blur'
          }],
        },
        field109Action: 'https://jsonplaceholder.typicode.com/posts/',
        field109fileList: [],
        field103Options: [{
          "label": "男",
          "value": 1
        }, {
          "label": "女",
          "value": 2
        }],
        field108Options: [{
          "label": "选项一",
          "value": 1
        }, {
          "label": "选项二",
          "value": 2
        }],
        field122Options: [{
          "label": "选项一",
          "value": 1
        }, {
          "label": "选项二",
          "value": 2
        }],
      }
    },
    computed: {},
    watch: {},
    created() {},
    methods: {
     /* findUser(uname){   //user?????
        this.$axios.get("http://127.0.0.1:8999/user/findByName?uname="+uname).then(res=>{
          if(res.data.code==200){
            /!*this.formData.field101=res.data[0].uName;*!/
            this.userList=res.data.data.records
          }});
      },*/

      submitForm() {
        this.$refs['elForm'].validate(valid => {
          if (!valid) return
          // TODO 提交表单
          console.log(this.user)
          this.$axios.post("http://127.0.0.1:8999/user/saveUser",this.user).then(res=>{
            if(res.data.code==200){
              this.$message.success('信息修改成功')
              this.$router.push({path:"/userList"})
            }
          })
        })
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
      field109BeforeUpload(file) {
        let isRightSize = file.size / 1024 / 1024 < 2
        if (!isRightSize) {
          this.$message.error('文件大小超过 2MB')
        }
        return isRightSize
      },
      },

    /*mounted() {
      alert("777777"),
        name = this.$route.params.name;
      alert(name);
      this.findUser(name);
    },*/
    mounted(){
      this.user = this.$route.params.user;
    }


  }

</script>
<style>
  .el-upload__tip {
    line-height: 1.2;
  }

</style>
